package org.liuhy.line
{
	import flash.events.MouseEvent;
	import flash.geom.Point;
	
	import mx.collections.ArrayCollection;
	import mx.controls.Text;
	import mx.core.UIComponent;
	import mx.events.DragEvent;
	
	import org.liuhy.node.focus.FocusNode;
	
	public class AbstractLine extends UIComponent
	{
		public var x1:int;
		public var y1:int;
		public var x2:int;
		public var y2:int;
		public var in_flowFocusNode:FocusNode 	= null;		//流程节点,入线口
		public var out_flowFocusNode:FocusNode 	= null;		//流程节点,出线口	
		public var fromLineNode		:LineNode 	= null;			//线段开始Focus点;
		public var midLineNode		:LineNode 	= null;			//线段中间Focus点;

		public var arrowLineNode	:LineNode 	= null;				//线段最后一条险段箭头Focus点;
		public var _arrow:Arrow					= null;				//线段箭头;
		public var nextLine:AbstractLine 		= null;
		public var preLine:AbstractLine  		= null;
		private var text:Text 					= new Text;
		public var cLine:CLine 					= null;
		private var _lineColor:uint					 = 0x000000;
		private var _lineNodeBorderColor:uint		 = 0x000000;
		private var _lineNodeBackgroundColor:uint	 = 0xFFFFFF;
		private var _virtualLineList:ArrayCollection = new ArrayCollection();

		public function AbstractLine(p_x1:int,p_y1:int,p_x2:int,p_y2:int,p_cLine:CLine)
		{	
			this.x1  = p_x1;
			this.y1  = p_y1;
			this.x2  = p_x2;
			this.y2  = p_y2;
			this.cLine = p_cLine;
			this._lineColor 				= this.cLine.lineColor;
			this._lineNodeBackgroundColor 	= this.cLine.lineNodeBackgroundColor;
			this._lineNodeBorderColor		= this.cLine.lineNodeBorderColor;
			this.fromLineNode = new FromLineNode(p_x1-50,p_y1);
			this.addChild(fromLineNode);			
			this.fromLineNode.visible 	= true;
			this.cLine.addChild(this);
			this.addEventListener(MouseEvent.CLICK,onClick);

		}
		//使线段能够被选中，删除(问题),???能删除就不能拖动LineNode节点
		private function onClick(event:MouseEvent):void{
//			event.stopPropagation();
		}
		public function removeAllVirtualLine():void{
			for(var i:int=0;i<this._virtualLineList.length;i++){
				this.cLine.removeChild(this._virtualLineList.getItemAt(i) as AbstractLine);
			}
		}
		public function addVirtuaLine(p_line:AbstractLine):void{
			this._virtualLineList.addItem(p_line);
		}
		public function getLineLen():int{
			 return Point.distance(new Point(this.x1,this.y1),new Point(this.x2,this.y2));
		}
		//画线
		public function draw():void{

		}
		//画虚线;
		public function virtualDraw():void{
			
		}		
		//移动fromNode节点调整线;
		public function fromNodeAdjustLine(p_event:DragEvent):void{
			
		}
		//移动开始结点虚线;
		public function fromNodeAdjustVirtualLine(p_event:DragEvent):void{
			
		}
		public function fromNodeFocusAdjustVirtualLine(p_focusNode:FocusNode):void{
			
		}		
		//移动中间节点调整线;
		public function midNodeAdjustLine(p_event:DragEvent):void{
		}
		//移动中间结点虚线;
		public function midNodeAdjustVirtualLine(p_event:DragEvent):void{
			
		}
		//移动箭头节点调整线;
		public function arrowNodeAdjustLine(p_event:DragEvent):void{
			
		}
		//移动箭头结点虚线;
		public function arrowNodeAdjustVirtualLine(p_event:DragEvent):void{
			
		}
		//移动箭头结点虚线(在flownode focus上);
		public function arrowNodeFocusAdjustVirtualLine(p_focusNode:FocusNode):void{
			
		}
		
		public function focusNodeDropArrowLine(p_focusNode:FocusNode):void{
			
		}
		public function focusNodeDropFromLine(p_focusNode:FocusNode):void{
			
		}
		public function focusNodeAdjustArrowLine(p_focusNode:FocusNode):void{
			
		}
		public function focusNodeAdjustFromLine(p_focusNode:FocusNode):void{
			
		}
		public function setFocusVisible(p_bool:Boolean):void{
			
		}
		public function set lineColor(p_color:uint):void{
			this._lineColor = p_color;
		}
		public function get lineColor():uint{
			return this._lineColor;
		}
		public function set lineNodeBorderColor(p_color:uint):void{
			this._lineNodeBorderColor = p_color;
		}
		public function get lineNodeBorderColor():uint{
			return this._lineNodeBorderColor;
		}
		public function set lineNodeBackgroundColor(p_color:uint):void{
			this._lineNodeBackgroundColor = p_color;
		}
		public function get lineNodeBackgroundColor():uint{
			return this._lineNodeBackgroundColor;
		}
	}
}